# Title     : TODO
# Objective : TODO
# Created by: Administrator
# Created on: 2019/7/24

library(ggrepel)
library(ropls)
library(pROC)
library(egg)
library(randomForest)
library(Boruta)
library(magrittr)
library(e1071)
library(optparse)
library(tidyverse)

createWhenNoExist <- function(f) {
  !dir.exists(f) && dir.create(f)
}

option_list <- list(
  make_option("--cc", default = "calculate_config.json", type = "character", help = "config file")

)
opt <- parse_args(OptionParser(option_list = option_list))

options(digits = 3)

args <- commandArgs(trailingOnly = F)
scriptPath <- dirname(sub("--file=", "", args[grep("--file", args)]))
source(str_c(scriptPath, "/base.R"))

configJson <- fromJSON(opt$cc)
topM <- configJson$topM %>%
  as.numeric()

fileName <- "SVM_Imp_Rank.csv"
if (!file.exists(fileName)) {
  quit(status = 0)
}

outTb<-read_csv(fileName) %>%
  slice(1:topM) %>%
  select(c("Metabolite"))

write_csv(outTb, "Diff_Metabolite.csv")







